import java.io.BufferedReader;
import java.io.FileReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Random;
import java.util.StringTokenizer;

import utils.Layer;
import utils.Ligne;




public class SomaReader {
	
	private String traite(char c,int x,int y,int z){
		if((c!='0')&&(c!='.')&&(c!='-'))
			return "object{boite translate<"+x+","+(y-1)+","+(z-1)+"> texture{Text"+c+"} finish{Fin"+c+"}}";
		else return "";
		
	}

	
	public SomaReader() throws Exception{
		 ArrayList<Layer>description=new ArrayList<Layer>();	
	      //BufferedReader in = new BufferedReader(new FileReader("/tmp/inSoma.txt"));
	     BufferedReader in = new BufferedReader(new FileReader("C:\\Documents and Settings\\Francesco\\Bureau\\soma.txt"));
			String ligne = in.readLine();
			
			ligne=in.readLine();
			while (ligne != null) {
				StringTokenizer st=new StringTokenizer(ligne,"/");
				Layer coucheCourante=new Layer();
				while(st.hasMoreTokens()){
					String curr=st.nextToken(); 
					coucheCourante.addLigne(new Ligne(curr)); 
					System.out.println(curr);
					
				
				}
				description.add(coucheCourante);
				ligne = in.readLine();
			}
			in.close();
			
			/*
			for(Layer l:description)
				System.out.println(l);
			*/
			
			for(int zc=0;zc<description.size();zc++){ // decrire un layer
				Layer lcourant=description.get(zc); 
				int prof=description.size()-1-zc; 
				int pY=lcourant.size();
				for(int i=0;i<pY;i++){
					Ligne ligc=lcourant.getLigne(i); 
					for(int j=0;j<ligc.length();j++){
						String resu=traite(ligc.getToken(j),j,pY-i,prof); 
						if(resu!="")
						System.out.println(resu);
					}
				}
				
			}
			
			System.out.println("** " +description.size()); 
			/*
			try {PrintStream output=new PrintStream("/tmp/outSoma.txt");
			
			}
			catch(Exception e){System.out.println(e); }
			*/
	}
	public static void main(String[] args) throws Exception{
		SomaReader hh=new SomaReader(); 
	}

}
